﻿using System.Windows;
using System.Windows.Controls;
using SimpleJackInterface.ViewModel;

namespace SimpleJackInterface
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Say();
        }

        private void Say()
        {
            MainViewModel mvm = (MainViewModel)this.DataContext;

            mvm.ChatLogViewModel.AddChatLogItemCommand.Execute(new ChatLogItemViewModel(eChatter.User, txtInput.Text));
            txtInput.Text = "";
        }

        private void txtInput_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == System.Windows.Input.Key.Enter)
            {
                Say();
            }
        }

    }
}